package com.smedi.ismedi.constructionproject.core.port.adapter.persistence.mybatis.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smedi.ismedi.constructionproject.core.application.query.vo.ProjectAssignmentVo;
import com.smedi.ismedi.constructionproject.core.port.adapter.persistence.model.ProjectAssignmentEntity;
import com.smedi.ismedi.database.starter.annotation.SqlItem;
import com.smedi.ismedi.database.starter.annotation.SqlPermission;
import com.smedi.ismedi.database.starter.interceptor.permission.SqlItemEnum;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Author: xulinjun
 * @Date: 2021-6-8 10:52
 */
@SqlPermission({
        @SqlItem(item = SqlItemEnum.project, table = {ProjectAssignmentEntity.class})
})
public interface ProjectAssignmentMapper extends BaseMapper<ProjectAssignmentEntity> {
    IPage<ProjectAssignmentVo> selectPaginationWithPersonIds(Page<ProjectAssignmentVo> page,
                                                             @Param("projectId") Long projectId,
                                                             @Param("projectOrganizationId") Long projectOrganizationId,
                                                             @Param("segPersonIds") List<List<Long>> segPersonIds);

    IPage<ProjectAssignmentVo> selectPaginationWithPersonIdsContainsProjectOrganizationChildren(Page<ProjectAssignmentVo> page,
                                                                                                @Param("projectId") Long projectId,
                                                                                                @Param("segProjectOrganizationIds") List<List<Long>> segProjectOrganizationIds,
                                                                                                @Param("segPersonIds") List<List<Long>> segPersonIds);

    IPage<ProjectAssignmentVo> selectPaginationByProjectIdAndProjectOrganizationId(Page<ProjectAssignmentVo> page,
                                                                                   @Param("projectId") Long projectId,
                                                                                   @Param("projectOrganizationId") Long projectOrganizationId);


    IPage<ProjectAssignmentVo> selectPaginationContainsProjectOrganizationChildren(Page<ProjectAssignmentVo> page,
                                                                                   @Param("projectId") Long projectId,
                                                                                   @Param("segProjectOrganizationIds") List<List<Long>> segProjectOrganizationIds);

    List<Long> selectProjectIdsByPersonId(@Param("personId") Long personId);

    List<ProjectAssignmentVo> selectContainsProjectOrganizationChildren(@Param("projectId") Long projectId,
                                                                        @Param("segProjectOrganizationIds") List<List<Long>> segProjectOrganizationIds);

    List<ProjectAssignmentVo> selectWithPersonIdsContainsProjectOrganizationChildren(@Param("projectId") Long projectId,
                                                                                     @Param("segProjectOrganizationIds") List<List<Long>> segProjectOrganizationIds,
                                                                                     @Param("segPersonIds") List<List<Long>> segPersonIds);

    List<ProjectAssignmentVo> selectByProjectIdAndProjectOrganizationId(@Param("projectId") Long projectId,
                                                                        @Param("projectOrganizationId") Long projectOrganizationId);


    List<ProjectAssignmentVo> selectWithPersonIds(
            @Param("projectId") Long projectId,
            @Param("projectOrganizationId") Long projectOrganizationId,
            @Param("segPersonIds") List<List<Long>> segPersonIds);
}
